export const FormFunc = {
	computed: {
        type() {
            return this.form.id ? '修改' : '创建'
        }
    },
	methods: {
		onSubmit() {
			let url = this.url + (this.form.id ? '/' + this.form.id : '');
        	let method = this.form.id ? 'patch' : 'post';
        	this.$http[method](url, this.form).then((response) => {
                this.$notify({
                    title: '操作成功',
                    message: '数据已' + this.type,
                    type: 'success'
                })
        		this.$router.push('/' + this.url + 's');
        	});
		},
		cancel() {
			this.$router.back();
		}
	}
}